import { docx_url as url } from './config';
export default `
	<a href='${url}/create-docx' style='color:blue;'>生成docx</a>

	<a href="https://docx.js.org/#/" target="_blank" style="color:red;margin-right:10px;">文档地址</a>
	实现代码:
	<div><textarea cols=80 rows=50>
	引入：
	import * as docx from 'docx';
	import * as fs from 'fs';

	1.创建docx
	const doc = new docx.Document();

	2.创建段落
	const paragraph = new docx.Paragraph('这是一段文字');

	3.添加到document
	doc.addParagraph(paragraph);

	4.创建包装器
	const packer = new docx.Packer();

	5.创建docx文件
	const res = await (() => {
		return new Promise<Buffer>((resolve, reject) => {
			packer.toBuffer(doc).then(async (buffer) => {
				resolve(buffer);
			});
		})
	})();
	return {
		attachment: 'test.docx',
		buff: res,
		content_type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
	};

	现在就创建了一个简单的docx文件,还可以做一下其他的操作

	样式：
	创建带样式的段落 标题1~标题5
	/**
	 * heading1()
	 * heading2()
	 * heading3()
	 * heading4()
	 * heading5()
	 */
	const paragraph_heading = new docx.Paragraph('我是标题1');
	paragraph_heading.heading1();
	添加到document
	doc.addParagraph(paragraph_heading);

	创建标题段落
	const paragraph_title = new docx.Paragraph('我是标题');
	paragraph_title.title();
	添加到document
	doc.addParagraph(paragraph_title);

	创建文字对齐段落:中心对齐
	const paragraph_center = new docx.Paragraph('我是中心对齐的文字');
	paragraph_center.center();
	添加到document
	doc.addParagraph(paragraph_center);

	左对齐
	const paragraph_left = new docx.Paragraph('我是左对齐的文字');
	paragraph_left.left();
	添加到document
	doc.addParagraph(paragraph_left);

	右对齐
	const paragraph_right = new docx.Paragraph('我是右对齐的文字');
	paragraph_right.right();
	添加到document
	doc.addParagraph(paragraph_right);

	标题1右对齐
	const paragraph_c_r = new docx.Paragraph('我是标题1右对齐的文字');

	reight()跟heading1() 没有顺序 谁先谁后都行.

	paragraph_c_r.right().heading1();
	添加到document
	doc.addParagraph(paragraph_c_r);

	分割线
	var p_thematicBreak = new docx.Paragraph().thematicBreak();
	添加到document
	doc.addParagraph(p_thematicBreak);

	</textarea></div>
`;
